// const url=require("url");
// // console.log(url)
// let str=url.parse("http://localhost:127.0.0.1:8080/show>age<30&id>10")
// console.log(str)


// let url_3={
//     hostname:"localhost",
//     port:8080,
//     protocol:"https",
//     pathname:"show",
//     search:"?age=20"
// }
// console.log(url.format(url_3));


const http=require("http")
const server=http.createServer((req,resp)=>{
    let url1=req.url
    // console.log(url1)
    // let url2=url.parse("http://localhost:9000"+url1,true);
    let url3=new URL("http://localhost:9000"+url1)
    console.log(url3.pathname)

    resp.setHeader("content-type","text/html;charset=utf-8")
    if(url3.pathname=="login"){
        resp.end("登录页面");
    }else if(url3.pathname=="register"){
        resp.end("注册页面");
    }else{
        resp.end("欢迎光临");
    }
    resp.end("Hello!你好")
})
server.listen(9000,()=>{
    console.log("已启动服务");
})
